/**
 * Validation code for User Registration page
 */

function validation()
{
	var userid = document.forms["registration"]["ssn"].value;
	var passwd = document.forms["registration"]["passwd"].value;
	var cpasswd = document.forms["registration"]["cpasswd"].value;
	var firstName = document.forms["registration"]["firstName"].value;
	var lastName = document.forms["registration"]["lastName"].value;
	var email = document.forms["registration"]["emailId"].value;
	var city = document.forms["registration"]["city"].value;
	var mobile = document.forms["registration"]["mobileNo"].value;
	//alert(firstName);
	//var mobile = document.forms["registration"]["mobile_no"].value;
	if (userid == "") {
		// document.getElementById('val').innerHTML='<font color="red">User Invalid</font>';
		document.getElementById('user').innerHTML = 'Can not be empty';
		return false;
	}
	else if (userid.length<6 || userid.length>10) {
		document.getElementById('user').innerHTML = 'Should be between 6 to 10 character';
		return false;
	}
	 // allow only letters, numbers, and underscores
    var i = /[\W_]/;
	  if(i.test(userid))
    {
    	document.getElementById('user').innerHTML = 'Contains illegal characters';
        return false;
	    } 
	else{
		document.getElementById('user').innerHTML = '';
		}
	if (passwd == "") {
		document.getElementById('password').innerHTML = 'Can not be empty';
		return false;
	}
	else if (passwd.length<6 || passwd.length>10) {
		document.getElementById('password').innerHTML = 'Should be between 6 to 10 character';
		return false;
	}
	else
	{
		document.getElementById('password').innerHTML = '';
		}
	 if (cpasswd=="" || !(passwd==cpasswd))
	{
		document.getElementById('cpassword').innerHTML = 'Confirm password';
		
		cpasswd="";
		return false;
		} 
	 else
	 {
		 document.getElementById('cpassword').innerHTML = '';
		 }
	if(firstName == "" )
	{
		//alert(firstName);
		document.getElementById('fname').innerHTML = 'Enter first name';
		
		return false;
	}
	var i;
	for(i=0;i<=9;i++)
	   {
			if(firstName.indexOf(i)>=0)
			{
				//alert(firstName);
				document.getElementById('fname').innerHTML = 'Number is not allowed';
				return false;
				}
		   }

	
	 // allow only letters, numbers, and underscores
    var x = /[\W_]/;
	  if(x.test(firstName))
    {
    	document.getElementById('fname').innerHTML = 'Contains illegal characters';
        return false;
	    }
	  if(1)
	  {
		  document.getElementById('fname').innerHTML = '';
		  }
	  if(lastName == "" )
		{
			//alert(firstName);
			document.getElementById('lname').innerHTML = 'Enter last name';
			
			return false;
		}
		var i;
		for(i=0;i<=9;i++)
		   {
				if(lastName.indexOf(i)>=0)
				{
					//alert(firstName);
					document.getElementById('lname').innerHTML = 'Number is not allowed';
					return false;
					}
			   }

		 // allow only letters, numbers, and underscores
	    var x = /[\W_]/;
		  if(x.test(lastName))
	    {
	    	document.getElementById('lname').innerHTML = 'Contains illegal characters';
	        return false;
		    }
		  if(1)
		  {
			  document.getElementById('lname').innerHTML = '';
			  }
	  
	   if(isNaN(mobile))
       {
          document.getElementById('mobile').innerHTML = 'Must contain numbers only';
          return false; 
       }
       if (mobile.length!=10)
       {
            document.getElementById('mobile').innerHTML = 'Enter 10 digit number';
            return false;
       }
       else
       {
    	   document.getElementById('mobile').innerHTML = '';
           }
	  if(email==""||email.indexOf("@")<1||email.indexOf(".")<1)
		{
			//alert("please enter valid email id");
			document.getElementById('email').innerHTML = 'Enter valid email id';
			return false;
		}
	  else
	  {
		  document.getElementById('email').innerHTML = '';
		  }
	  if(city == "")
		 
		{
		 document.getElementById('cty').innerHTML = 'Enter city';
			return false;
		}
		else 
		{
			 for(i=0;i<=9;i++)
			   {
					if(city.indexOf(i)>=0)
					{
						 document.getElementById('cty').innerHTML = 'Numbers not allowed';
						return false;
						}
				   }
			}
	return true;
	}
